<?php
/**
 * BalanceData
 *
 * PHP version 7.2
 *
 * @category Class
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * OEML - REST API
 *
 * This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>
 *
 * The version of the OpenAPI document: v1
 * Contact: support@coinapi.io
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 5.0.1
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace OpenAPI\Client\Model;

use \ArrayAccess;
use \OpenAPI\Client\ObjectSerializer;

/**
 * BalanceData Class Doc Comment
 *
 * @category Class
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<TKey, TValue>
 * @template TKey int|null
 * @template TValue mixed|null  
 */
class BalanceData implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $openAPIModelName = 'Balance_data';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'asset_id_exchange' => 'string',
        'asset_id_coinapi' => 'string',
        'balance' => 'float',
        'available' => 'float',
        'locked' => 'float',
        'last_updated_by' => 'string',
        'rate_usd' => 'float',
        'traded' => 'float'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string|null>
      * @psalm-var array<string, string|null>
      */
    protected static $openAPIFormats = [
        'asset_id_exchange' => null,
        'asset_id_coinapi' => null,
        'balance' => 'float',
        'available' => 'float',
        'locked' => 'float',
        'last_updated_by' => null,
        'rate_usd' => 'float',
        'traded' => 'float'
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'asset_id_exchange' => 'asset_id_exchange',
        'asset_id_coinapi' => 'asset_id_coinapi',
        'balance' => 'balance',
        'available' => 'available',
        'locked' => 'locked',
        'last_updated_by' => 'last_updated_by',
        'rate_usd' => 'rate_usd',
        'traded' => 'traded'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'asset_id_exchange' => 'setAssetIdExchange',
        'asset_id_coinapi' => 'setAssetIdCoinapi',
        'balance' => 'setBalance',
        'available' => 'setAvailable',
        'locked' => 'setLocked',
        'last_updated_by' => 'setLastUpdatedBy',
        'rate_usd' => 'setRateUsd',
        'traded' => 'setTraded'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'asset_id_exchange' => 'getAssetIdExchange',
        'asset_id_coinapi' => 'getAssetIdCoinapi',
        'balance' => 'getBalance',
        'available' => 'getAvailable',
        'locked' => 'getLocked',
        'last_updated_by' => 'getLastUpdatedBy',
        'rate_usd' => 'getRateUsd',
        'traded' => 'getTraded'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    const LAST_UPDATED_BY_INITIALIZATION = 'INITIALIZATION';
    const LAST_UPDATED_BY_BALANCE_MANAGER = 'BALANCE_MANAGER';
    const LAST_UPDATED_BY_EXCHANGE = 'EXCHANGE';
    

    
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getLastUpdatedByAllowableValues()
    {
        return [
            self::LAST_UPDATED_BY_INITIALIZATION,
            self::LAST_UPDATED_BY_BALANCE_MANAGER,
            self::LAST_UPDATED_BY_EXCHANGE,
        ];
    }
    

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['asset_id_exchange'] = $data['asset_id_exchange'] ?? null;
        $this->container['asset_id_coinapi'] = $data['asset_id_coinapi'] ?? null;
        $this->container['balance'] = $data['balance'] ?? null;
        $this->container['available'] = $data['available'] ?? null;
        $this->container['locked'] = $data['locked'] ?? null;
        $this->container['last_updated_by'] = $data['last_updated_by'] ?? null;
        $this->container['rate_usd'] = $data['rate_usd'] ?? null;
        $this->container['traded'] = $data['traded'] ?? null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        $allowedValues = $this->getLastUpdatedByAllowableValues();
        if (!is_null($this->container['last_updated_by']) && !in_array($this->container['last_updated_by'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value '%s' for 'last_updated_by', must be one of '%s'",
                $this->container['last_updated_by'],
                implode("', '", $allowedValues)
            );
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets asset_id_exchange
     *
     * @return string|null
     */
    public function getAssetIdExchange()
    {
        return $this->container['asset_id_exchange'];
    }

    /**
     * Sets asset_id_exchange
     *
     * @param string|null $asset_id_exchange Exchange currency code.
     *
     * @return self
     */
    public function setAssetIdExchange($asset_id_exchange)
    {
        $this->container['asset_id_exchange'] = $asset_id_exchange;

        return $this;
    }

    /**
     * Gets asset_id_coinapi
     *
     * @return string|null
     */
    public function getAssetIdCoinapi()
    {
        return $this->container['asset_id_coinapi'];
    }

    /**
     * Sets asset_id_coinapi
     *
     * @param string|null $asset_id_coinapi CoinAPI currency code.
     *
     * @return self
     */
    public function setAssetIdCoinapi($asset_id_coinapi)
    {
        $this->container['asset_id_coinapi'] = $asset_id_coinapi;

        return $this;
    }

    /**
     * Gets balance
     *
     * @return float|null
     */
    public function getBalance()
    {
        return $this->container['balance'];
    }

    /**
     * Sets balance
     *
     * @param float|null $balance Value of the current total currency balance on the exchange.
     *
     * @return self
     */
    public function setBalance($balance)
    {
        $this->container['balance'] = $balance;

        return $this;
    }

    /**
     * Gets available
     *
     * @return float|null
     */
    public function getAvailable()
    {
        return $this->container['available'];
    }

    /**
     * Sets available
     *
     * @param float|null $available Value of the current available currency balance on the exchange that can be used as collateral.
     *
     * @return self
     */
    public function setAvailable($available)
    {
        $this->container['available'] = $available;

        return $this;
    }

    /**
     * Gets locked
     *
     * @return float|null
     */
    public function getLocked()
    {
        return $this->container['locked'];
    }

    /**
     * Sets locked
     *
     * @param float|null $locked Value of the current locked currency balance by the exchange.
     *
     * @return self
     */
    public function setLocked($locked)
    {
        $this->container['locked'] = $locked;

        return $this;
    }

    /**
     * Gets last_updated_by
     *
     * @return string|null
     */
    public function getLastUpdatedBy()
    {
        return $this->container['last_updated_by'];
    }

    /**
     * Sets last_updated_by
     *
     * @param string|null $last_updated_by Source of the last modification.
     *
     * @return self
     */
    public function setLastUpdatedBy($last_updated_by)
    {
        $allowedValues = $this->getLastUpdatedByAllowableValues();
        if (!is_null($last_updated_by) && !in_array($last_updated_by, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value '%s' for 'last_updated_by', must be one of '%s'",
                    $last_updated_by,
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['last_updated_by'] = $last_updated_by;

        return $this;
    }

    /**
     * Gets rate_usd
     *
     * @return float|null
     */
    public function getRateUsd()
    {
        return $this->container['rate_usd'];
    }

    /**
     * Sets rate_usd
     *
     * @param float|null $rate_usd Current exchange rate to the USD for the single unit of the currency.
     *
     * @return self
     */
    public function setRateUsd($rate_usd)
    {
        $this->container['rate_usd'] = $rate_usd;

        return $this;
    }

    /**
     * Gets traded
     *
     * @return float|null
     */
    public function getTraded()
    {
        return $this->container['traded'];
    }

    /**
     * Sets traded
     *
     * @param float|null $traded Value of the current total traded.
     *
     * @return self
     */
    public function setTraded($traded)
    {
        $this->container['traded'] = $traded;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed|null
     */
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed Returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource.
     */
    public function jsonSerialize()
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


